<include file="../Public/header" />
<link href="{:APPS_URL}/w3g/_static/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
  body{background-color: #f8f8f8;}
</style>
<div id="content">
    <div id="weiba" data-title="昵称" class="panel" data-selected="true"  data-menu="msgmenu" style="padding:0;">
        <header>
            <div id="header-buttons">
                <a href="javascript:history.go(-1);">
                    <div id="back" class="header-menu-link" data-back="false">
                    </div>
                </a>
            </div>
            <h1 class="hasback">
                昵称
            </h1>
        </header>
    <div class="set-item" id="">
      <div class="form-set">
        <dl class="noborder">
          <dd>
            <input class="text1" id="uname" old="{$user_info['uname']}" name="uname" autocomplete="off" type="text" value="{$user_info['uname']}" placeholder=""/>
          </dd>
        </dl>
      </div>
      <p class="sinfo">昵称为2-10位，支持中英文、数字、下划线</p>
      <div class="setBtn"><a href="javascript:;" class="btn-big" onclick="setName()">保存</a></div>
    </div>
</div>
<script type="text/javascript">
  function setName(){
    if($('#uname').val() == ''){
       $.ui.showMask("用户昵称不能为空",true);
      return;
    }
    if($('#uname').val() == $('#uname').attr('old')){
        location.href= U('w3g/Setting/base');
        return;
    }
    $.ajax({
      type : 'post',
      url : U('public/Register/isUnameAvailable'),
      data: {'uname': $('#uname').val()},
      timeout : 10000,
      dataType: 'json',
      success : function(d){
         if(d && d.status){
            $.ajax({
              type : 'post',
              url : location.href,
              data: {'uname': $('#uname').val()},
              timeout : 10000,
              dataType: 'json',
              success : function(d){
                 if(d && d.status){
                    location.href= U('w3g/Setting/base');
                 }else{
                   $.ui.showMask(d.info,true);
                 }
              },
              error: function(r){
                $.ui.showMask("连接服务器失败，请重试:)",true);
              }
            });
         }else{
            $.ui.showMask(d.info,true);
         }
      },
      error: function(r){
          $.ui.showMask("连接服务器失败，请重试:)",true);
      }
    });    
  }


</script>
<include file="../Public/footer" />